<html>
<head>
    <meta charset="utf-8">
    <title>销售入驻</title>
    <#assign base=request.contextPath  />
    <#setting  number_format="0.##"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${base}/frame/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${base}/sweep/css/app.css" media="all">
    <link rel="stylesheet" href="${base}/sweep/css/mui.min.css" media="all">
    <link rel="stylesheet" type="text/css" href="${base}/sweep/css/style.css" />
    <link rel="stylesheet" type="text/css" href="${base}/sweep/css/mui.picker.css"/>
    <link rel="stylesheet" type="text/css" href="${base}/sweep/css/mui.poppicker.css"/>
    <link rel="stylesheet" type="text/css" href="${base}/frame/layui/css/layui.css"/>
    <script src="${base}/backstage/js/jquery-1.8.3.min.js"></script>
    <script src="${base}/sweep/js/mui.min.js"></script>
    <script src="${base}/backstage/layui/layui.js"></script>
    <style>
        body {
            margin: 0 auto;
        }

        .ired {
            color: red;
        }

        .mui-btn-block {
            padding: 6px 0;
        }

        .mui-icon-arrowthindown {
            font-size: 14px;
            color: #007aff;
            font-weight: bold
        }

        .info_list {
            width: 100%;
            background-color: #f2f2f2;
            height: 40px;
            border-bottom: 1px solid #F2F2F2;
        }

        .list_left2 {
            width: 97%;
            margin-left: 3%;
            height: 40px;
            font-family: "微软雅黑";
            font-size: 13px;
            color: #000000;
            line-height: 40px;
            float: left;
            margin-bottom: 14px;
        }
        .list_left2 span {
            color: #A04E52;
            font-size: 10px;
            margin-left: 5px;
        }

        .id_img_wp {
            width: 94%;
            margin: 0 auto;
            min-height: 30px;
        }
        .img_wp {
            width: 40%;
            margin: 0 5% 0 5%;
            float: left;
            cursor: pointer;
        }
        .img_wp img {
            width: 100%;
            height: 100%;
        }
        .img_intro {
            color: #383838;
            text-align: center;
            font-family: "微软雅黑";
            padding: 10px 0 10px 0;
        }
        .mui-input-row {
            border-top: 1px solid #F2F2F2;
        }
        .mui-table-view:after {
            display: none;
        }
        .col2 {
            background-color: #F2F2F2;
        }
        .van-popup {
            background: none;
            color: white;
        }
        .van-overlay {
            display: none;
            background-color: rgba(0, 0, 0, 0.29);
        }
    </style>
</head>
<body>
<div class="mui-content">
    <div class="mui-content-padded" style="margin: 5px;">
        <input type="hidden" value="${user.openid}" id="openid"/>
        <form class="mui-input-group">
<#--            <div class="info_list" style="border-bottom:none;">-->
<#--                <div class="list_left2">营业执照<span>(请上传营业执照，图片保持清晰)</span></div>-->
<#--            </div>-->

<#--            <div class="layui-upload-drag" id="zhizhao" style="width: 100%;height: 26%;">-->
<#--                <i class="layui-icon"></i>-->
<#--                <p>点击上传，或将文件拖拽到此处</p>-->
<#--            </div>-->
            <div class="mui-input-row" >
                <label>姓名</label>
                <input type="text" id="name" class="mui-input-clear" placeholder="请输入真实姓名">
            </div>

            <div class="mui-input-row">
                <label>联系电话</label>
                <input type="text" id="phone" class="mui-input-clear" placeholder="请输入联系电话">
            </div>
            <div class="mui-input-row">
                <label>身份证号</label>
                <input type="text" id="idNumber" class="mui-input-clear" placeholder="请输入身份证号">
            </div>

<#--            <div class="mui-input-row">-->
<#--                <label>联系电话</label>-->
<#--                <input type="text" id="passWord" class="mui-input-clear" placeholder="请输入后台密码">-->
<#--            </div>-->

            <button id='showCityPicker3' type="button" class="mui-btn mui-btn-warning" style="float: right">选择地区</button>
            <div class="mui-input-row">
                <input type="text" id="cityResult3" class="ui-alert" placeholder="请输入选择居住地">
            </div>
            <div class="mui-input-row">
                <label>详细地址</label>
                <input type="text" id="xi" class="mui-input-clear" placeholder="请输入详细地址">
            </div>
            <div class="mui-input-row">
                <label>入驻费</label>
                <input type="text" id="money" value="199.00" disabled class="mui-input-clear" placeholder="请输入入驻费">
            </div>

        </form>


        <div class="info_list" style="border-bottom:none;">
            <div class="list_left2">身份证上传<span>(请上传身份证正面，图片保持清晰)</span></div>
        </div>
        <div class="layui-upload-drag" id="sfz" style="width: 100%;height: 26%;">
            <i class="layui-icon"></i>
            <p>点击上传，或将文件拖拽到此处</p>
        </div>
        <div class="info_list" style="border-bottom:none;">
            <div class="list_left2">身份证上传<span>(请上传身份证反面，图片保持清晰)</span></div>
        </div>
        <div class="layui-upload-drag" id="sfzf" style="width: 100%;height: 26%;">
            <i class="layui-icon"></i>
            <p>点击上传，或将文件拖拽到此处</p>
        </div>
    </div>
</div>
<div class="mui-content" >
    <div class="mui-content-padded">
        <button type="button"  class="mui-btn mui-btn-warning mui-btn-block" onclick="saveDoctor()">提 交</button>
    </div>
</div>
</body>
<script>
    var sfz = "";
    var sfzf = "";
    var layer;
    layui.use(['form', 'layer', 'upload'], function () {
        var form = layui.form
            , $ = layui.jquery
            , upload = layui.upload;
        layer = layui.layer


        //身份证正面
        upload.render({
            elem: '#sfz'
            ,url: '${base}/admin/file/uploadFile'
            , before: function (obj) {
                layer.load(); //上传loading
            }
            ,done: function(res){
                layer.closeAll('loading'); //关闭loading
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                $("#sfz i").remove()
                $("#sfz p").remove()
                $('#sfz').append('<img src="' + res.data + '" style="width: 100%;height: 100%">'); //图片链接（base64）
                sfz += res.data;
            }
        });
        //身份证正面
        upload.render({
            elem: '#sfzf'
            ,url: '${base}/admin/file/uploadFile'
            , before: function (obj) {
                layer.load(); //上传loading
            }
            ,done: function(res){
                layer.closeAll('loading'); //关闭loading
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                $("#sfzf i").remove()
                $("#sfzf p").remove()
                $('#sfzf').append('<img src="' + res.data + '" style="width: 100%;height: 100%">'); //图片链接（base64）
                sfzf += res.data;
            }
        });
    })
</script>
<script src="${base}/sweep/js/mui.picker.js"></script>
<script src="${base}/sweep/js/mui.poppicker.js"></script>
<script src="${base}/sweep/js/city.data.js" type="text/javascript" charset="utf-8"></script>
<script src="${base}/sweep/js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
<script>
    function saveDoctor() {

        if($("#name").val()=="") {
            layer.msg("姓名不能为空")
            return;
        }
        if($("#phone").val()==""){
            layer.msg("联系电话不能为空")
            return;
        }
        if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test($("#phone").val()))) {
            layer.msg("联系电话格式不对");
            return;
        }
        if($("#idNumber").val()==""){
            layer.msg("身份证号不能为空")
            return;
        }
        var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
        if(reg.test($("#idNumber").val()) === false) {
            layer.msg("身份证号格式不对");
            return;
        }
        if($("#cityResult3").val()==""){
            layer.msg("所在地址不能为空")
            return;
        }
        if($("#xi").val()==""){
            layer.msg("详细地址不能为空")
            return;
        }

        if(sfz==""){
            layer.msg("身份证正面不能为空")
            return;
        }
        if(sfzf==""){
            layer.msg("身份证反面不能为空")
            return;
        }


        var jsonDate = {
            name:$("#name").val(),
            phone:$("#phone").val(),
            money:$("#money").val(),
            idNumber:$("#idNumber").val(),
            address:$("#cityResult3").val()+$("#cityResult3").val(),
            positive:sfz,
            side:sfzf,
            openid:$("#openid").val(),
        }
        $.ajax({
            type: "POST",
            contentType: "application/json;charset=UTF-8",
            url: "${base}/wx/sale/saveOrUpdate",
            data:  JSON.stringify(jsonDate) ,
            beforeSend: function () {
                ShowDiv();
            },
            success: function (data) {
                if (data.code === 200) {
                    mui.alert("提交成功")
                    setTimeout(function () {
                        window.location.href = "${base}/wx/user/personal.html";
                    }, 300)
                } else {
                    mui.alert(data.msg)
                }
            },
            complete: function () {
                HiddenDiv();
            }
        });
        // })
    }
    //显示加载数据
    function ShowDiv() {
        $("#loading").show();
    }
    //隐藏加载数据
    function HiddenDiv() {
        $("#loading").hide();
    }

    (function($, doc) {
        $.init();
        $.ready(function() {
            var _getParam = function(obj, param) {
                return obj[param] || '';
            };
            var cityPicker3 = new $.PopPicker({
                layer: 3
            });
            cityPicker3.setData(cityData3);
            var showCityPickerButton = doc.getElementById('showCityPicker3');
            var cityResult3 = doc.getElementById('cityResult3');
            showCityPickerButton.addEventListener('tap', function(event) {
                cityPicker3.show(function(items) {
                    document.getElementById("cityResult3").value = "" + _getParam(items[0], 'text') + " " + _getParam(items[1], 'text') + " " + _getParam(items[2], 'text');
                });
            }, false);
        });
    })(mui, document);
</script>
</html>


